//package com.maweirdos.ai.config;
//
//import com.baomidou.dynamic.datasource.DynamicRoutingDataSource;
//import jakarta.annotation.Resource;
//import lombok.extern.slf4j.Slf4j;
//import org.springframework.ai.embedding.EmbeddingModel;
//import org.springframework.ai.vectorstore.VectorStore;
//import org.springframework.ai.vectorstore.pgvector.PgVectorStore;
//import org.springframework.context.annotation.Bean;
//import org.springframework.context.annotation.Configuration;
//import org.springframework.context.annotation.Primary;
//import org.springframework.jdbc.core.JdbcTemplate;
//
//import javax.sql.DataSource;
//
///**
// * Author:  Maweirdos
// * Date:  2025/7/9 23:22
// * Description:  向量数据库配置
// *
// * 注意：此配置类仅用于初始化数据库结构，
// * PgVectorStore实例会由spring-ai-pgvector-store-spring-boot-starter自动创建
// */
//@Configuration
//@Slf4j
//public class VectorStoreConfig {
//
//    @Resource
//    private EmbeddingModel embeddingModel;
//
//    @Resource
//    private DataSource dataSource; // 动态路由数据源
//
//    /**
//     * 默认注册 pgVectorStore 为 VectorStore，供 @Autowired 注入
//     */
//    @Bean
//    @Primary
//    public VectorStore vectorStore() {
//        // 通过 dynamic-datasource 获取名为 postgres 的实际 DataSource
//        DataSource postgres = ((DynamicRoutingDataSource) dataSource).getDataSource("postgres");
//        JdbcTemplate jdbcTemplate = new JdbcTemplate(postgres);
//        return PgVectorStore.builder(jdbcTemplate, embeddingModel).build();
//    }
//}
